package com.zhu.algorithm.jzOffer.otherJZ;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zhujiabao
 * @Date: 2023/01/28/20:10
 * @Description: JZ5 替换空格
 */
public class Solution05 {

    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param s string字符串
     * @return string字符串
     */
    public String replaceSpace (String s) {
        // write code here
        StringBuilder stringBuilder = new StringBuilder();
        for (char i : s.toCharArray()) {
            if (i == ' ') {
                stringBuilder.append("%20");
            } else {
                stringBuilder.append(i);
            }
        }
        return stringBuilder.toString();


    }
}
